<template>
  <el-dialog
    :visible.sync="$store.state.dias.courier.show"
    width="500px"
    center
    class="address-add"
    title="填写物流单号"
    >
    <main>
      <div v-for="(item, index) in modelData" :key="index" class="box mb20">
        <span class="title">{{item.label}}：</span>
        <el-input v-if="item.isInput" v-model="info[item.prop]" :placeholder="'请输入'+item.label" class="" :maxlength="item.max"></el-input>
        <el-button type="primary" v-if="item.button" class="btn" @click="item.button.click">{{item.button.label}}</el-button>
      </div>
    </main>
    <div slot="footer" class="dialog-footer">
      <el-button type="info" class="w120" @click="$store.state.dias.courier.show = false">取 消</el-button>
      <el-button type="success" class="w120" @click="submit">提 交</el-button>
    </div>
  </el-dialog>
</template>
<script>
import ComAddress from '@/components/address.vue'
export default {
  props:['id'],
  components: {ComAddress},
  name: "",
  data() {
    return {
      modelData:[
        {prop:"logistics",label:"物流公司",isInput:true,checked:true},
        {prop:"logisticsNum",label:"物流单号",isInput:true,checked:true},
      ],
      info:{
        logistics:"",
        logisticsNum:"",
      }
    };
  },
  methods: {
    handleAddress(val){
      this.info[val.key]=val.value
    },
    submit(){
      let params = this.info
      params.id=this.id
      if(_g.checkParams(this.modelData,params))return
      _g.apiPost('sellerOrder/writeLogisticsNum.do',params,true).then(res=>{
        if(res!==undefined){
          _g.toMessage(res)
          if(res.status==0){
            this.$emit('flash')
            this.$store.state.dias.courier.show=false
          }
        }
      })
    }
  },
  created() {}
};
</script>
<style lang="scss" scoped>
.address-add {
  font-size: 14px;
  main{
    padding: 10px 20px 10px 0;
    div.box{
      display: flex;
      line-height: 36px;

      .title{
        display: inline-block;
        min-width: 75px;
        margin-right: 10px;
        text-align: right;
      }
      .btn{
        padding: 0 5px;
        font-size: 12px;
        border-radius: 0;
        margin-left: 10px;
        min-width: 100px;
      }
    }
    div:nth-last-of-type(1){
      margin-bottom: 0;
    }
  }
  .w120{
    width: 150px;
  }
  .dialog-footer{
    padding-bottom: 20px;
  }
}
</style>